/**
 * @tag models, home
 * Wraps backend important_dates services.  Enables 
 * [Bugstat.Models.ImportantDates.static.findAll retrieving],
 * [Bugstat.Models.ImportantDates.static.update updating],
 * [Bugstat.Models.ImportantDates.static.destroy destroying], and
 * [Bugstat.Models.ImportantDates.static.create creating] important_dates.
 */
$.Model.extend('Bugstat.Models.ImportantDates',
/* @Static */
{
	/**
     * Retrieves important dates from your backend services.
	 *
     * @param {Object}   params   Params that might refine your results.
     * @param {Function} success  A callback function that returns wrapped important_dates objects.
     * @param {Function} error   A callback function for an error in the ajax request.
     */
    findAll : function(params, success, error){
        $.ajax({
            url: 'reports/important_dates.get',
            type: 'get',
            dataType: 'json',
            data: params,
            success: this.callback( ['wrap',success] ),
			error: error
        })
    }
},
/* @Prototype */
{
	fixTimestamps: function ()	
	{ 
		// first correct the timestamps - they are recorded as the daily
	    // midnights in UTC+0100, but Flot always displays dates in UTC
	    // so we have to add one hour to hit the midnights in the plot
	    for (var i = 0; i < this.dates.length; ++i)
		{
			this.dates[i][0] += 60 * 60 * 1000;
		}
	}	
	
});